package com.longcai.controller.nearby;


import com.alibaba.fastjson.JSONObject;
import com.longcai.bean.ApiResult;
import com.longcai.service.nearby.ClyjShopsTradingService;
import com.longcai.service.nearby.ClyjTradingAreaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 商圈表 前端控制器
 * </p>
 *
 * @author M
 * @since 2019-04-02
 */
@Controller
@RequestMapping("/clyjTradingArea")
public class ClyjTradingAreaController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private ClyjTradingAreaService clyjTradingAreaService;

    /**
     * 根据地址获取附近商圈
     *
     * @param params
     * @return
     */
    @RequestMapping("/getTradingArea")
    @ResponseBody
    public ApiResult getTradingArea(@RequestBody JSONObject params) {
        String province = params.getString("province");
        String city = params.getString("city");
        String country = params.getString("country");
        if (province == null || city == null || country == null || province.equals("") || city.equals("") || country.equals("")) {
            logger.error("查询失败");
            return ApiResult.fail("查询失败");
        }
        return this.clyjTradingAreaService.getTradingArea(province, city, country);
    }
}